﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UtilsCache;
using UtilsORM;
using UtilsORM.MySqlData;

namespace GatewayServerService.Data
{
    public class DBIotDeviceVariableValueRlueCache
    {
        public DBIotDeviceVariableValueRlueCache()
        {

        }


        /// <summary>
        /// 缓存增加 获取变量可操作条件
        /// </summary>
        /// <param name="cguid"></param>
        /// <returns></returns>
        public iot_device_model_variable_value_rlue getVariableValueRlueByCache(string vr_guid)
        {

            iot_device_model_variable_value_rlue model = UtilMemoryCacheHelper.get<iot_device_model_variable_value_rlue>("getVariableValueRlueByCache" + vr_guid);
            if (model == null)
            {
                EFYihongIotContext ef = new EFYihongIotContext();
                model = ef.iot_device_model_variable_value_rlue.Where(c => c.vr_guid == vr_guid && c.vr_status == 0).FirstOrDefault();
                UtilMemoryCacheHelper.set("getVariableValueRlueByCache" + vr_guid, model, 1);
            }
            return model;
        }

    }
}
